package com.itheima.ssm.dao;

import com.itheima.ssm.domain.Role;
import org.apache.ibatis.annotations.*;


import java.util.List;

public interface IRoleDao {
    @Select("select * from  role r ,users_role  u " +
            "  where r.id=u.roleId  and  u.userId=#{uId}")
    @Results({@Result(id = true,property ="id",column ="id" ),
            @Result(property = "permissions",column ="id" ,javaType =List.class ,
            many = @Many(select = "com.itheima.ssm.dao.IPermissionDao.findById"))
                    })
    public List<Role>findById(String uId);



    @Select("select * from role")
    public List<Role> findAll();

    @Insert("insert into role(roleName,roleDesc) values(#{roleName},#{roleDesc})")
  public  void save(Role role);


    @Select("select * from role where  id not in(select roleId from  users_role  where userId=#{uid})")
    public List<Role> findByUserId(String uid);
}
